Skip to content

Add test coverage for untested DB methods#388

Open
WolfieLeader wants to merge 1 commit intosurrealdb:mainfrom
WolfieLeader:test-add-missing-db-method-coverage
Open

Add test coverage for untested DB methods#388
WolfieLeader wants to merge 1 commit intosurrealdb:mainfrom
WolfieLeader:test-add-missing-db-method-coverage

Conversation

@WolfieLeader
Copy link

Summary

Add suite test coverage for 5 public DB methods that previously had only example tests: Version, Let/Unset, Upsert, Invalidate.

Motivation

These methods are part of the public API but lacked proper test assertions in the test suite. Example tests verify they don't panic but don't validate return values or behavior. Main package coverage increases from 57.7% to 58.6%.

Tests Added

  • TestVersion — verifies Version() returns non-nil VersionData
  • TestLetUnset — verifies Let() sets variables readable via RETURN $var query, Unset() removes them so query returns nil
  • TestUpsert — verifies create-if-not-exists and update-if-exists behavior with RecordID targets
  • TestInvalidate — verifies session invalidation succeeds, re-signs in to avoid affecting other tests

Not Included

  • Info() — panics with nil pointer dereference when signed in as root (db.go:152 dereferences *info.Result without a nil check, but the RPC returns null for root). This appears to be a bug — will report separately.
  • SignUp/SignUpWithRefresh/Authenticate — require complex setup (RECORD access methods, JWT keys). Better addressed in a separate PR.

Testing

  • make lint — 0 issues
  • make build — compiles cleanly
  • make test — passes (same baseline as main)
  • All new tests pass individually and in the full suite

These public DB methods had only example tests but no suite test
coverage with assertions. Follows the existing testify/suite
pattern in db_test.go. Coverage for the main package increases
from 57.7% to 58.6%.

Info() is excluded due to a nil pointer dereference when the RPC
returns a null result (db.go:152 dereferences *info.Result without
a nil check). This will be reported separately as a bug.
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant